home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir41 / x10xa200.zip / JOYSTICK.CMD < prev    next >
OS/2 REXX Batch file  |  1993-10-16  |  3KB  |  63 lines

  1. #============================================================================
  2. #
  3. #       INPORT Demo Program for XA 
  4. #
  5. #       This command file shows you how to react to input 
  6. #       from the Game Adapter (Joystick Port). 
  7. #       NOTE: Certain functions require Registered version XA 2.x 
  8. #
  9. #       The current switch status of the joystick may be obtained by 
  10. #       reading in the data from port address 201H (hexadecimal).  This 
  11. #       status is then stored in the variable "GAME".
  12. #               GAME = INPORT 201H
  13. #
  14. #       The status of Button A is located in Bit 5 of GAME. If the bit is
  15. #       a '0', then the button is currently pressed. Otherwise, if the bit
  16. #       is '1', then button is released. The status of Button B is located 
  17. #       in Bit 4 of GAME. To determine the individual state of each button,
  18. #       each bit must be "masked", or isolated. A mask of 32 (Hex 20) is 
  19. #       applied (bit-wise AND, the "&" operator) for Button A. A mask of
  20. #       16 (Hex 10) is applied for Button B.
  21. #
  22. #       To reduce the number of CP-290 transmissions, another variable
  23. #       "MODULE" is assigned a value of the current state of the controlled
  24. #       module. This will prevent redundant transmissions.
  25. #
  26. #       In order to make this loop as efficient as possible, the statement
  27. #       "DISPLAY OFF" is used. Note that this file is in fact EXECUTING...
  28. #
  29. #
  30.  
  31. MODULE = OFF                         # Intialize state to Off
  32. DISPLAY OFF                          # Turn display off to speed execution
  33.  
  34. :LOOP                                # This is the beginning of the loop
  35. GAME = INPORT 201H                   # Read the joystick port
  36.  
  37. IF !(GAME & 20H)                     # Check Button A
  38.   IF (MODULE == OFF)                 # If module is currently Off...
  39.     DISPLAY ON                       # (turn display on so we can see cmd)
  40.     c2 on fast                       # ...Turn module On
  41.     DISPLAY OFF
  42.     MODULE = ON                      # ...update status of module to On
  43.   ENDIF
  44. # DOS c:\sblaster\vplay c:\sblaster\yr.voc    # Make SoundBlaster talk
  45. ENDIF
  46.  
  47. # Check Button B
  48. IF !(GAME & 10H)                     # Check Button B
  49.   IF (MODULE == ON)                  # If module is currently On...
  50.     DISPLAY ON                       # (turn display on so we can see cmd)
  51.     C2 off fast                      # ...Turn module Off
  52.     DISPLAY OFF
  53.     MODULE = OFF                     # ...update its status too
  54.   ENDIF
  55. # DOS c:\sblaster\vplay c:\sblaster\witch.voc
  56. ENDIF
  57.  
  58. GOTO LOOP                            # Keep repeating loop until <ESC> pressed.
  59.  
  60. :EXIT                                # Special label to search for when <ESC>.
  61. DISPLAY ON
  62. C2 OFF                               # Put module back into a known state.
  63.